package chatAI

import (
	"context"
	"user_srv/userclient"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type SimpleChatLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewSimpleChatLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SimpleChatLogic {
	return &SimpleChatLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *SimpleChatLogic) SimpleChat(req *types.SimpleChatRequst) (resp *types.Response, err error) {
	//
	// 调用rpc
	simple, err := l.svcCtx.UserRpc.SendChatSimple(l.ctx, &userclient.SimpleChatRequest{
		Content: req.Content,
	})

	// 处理rpc返回
	if err != nil {
		return &types.Response{Code: 400, Message: err.Error()}, nil
	}
	// 处理rpc返回
	return &types.Response{
		Code:    200,
		Message: "医生回复成功",
		Data:    simple.Reply,
	}, nil

}
